import { ref, h } from "vue";
import { render } from "@/utils";
import multiLine from "common/multiLine.vue";
import systemType from "common/systemType.vue";
import TagStatus from "@/components/TagStatus/index.vue";
import LinkText from "@/components/LinkText/index.vue";

export const columns = [
  {
    title: "群组名称",
    dataIndex: "name",
    fixed: "left",
    render: ({ record }) =>h(LinkText, { 
      label: record?.name,
      to:`/computing-mgmt/placement-group/detail/${record?.id}?name=${record?.name}`
    }),

    // width: 200,
  },
  {
    title: "层级",
    dataIndex: "status",
    // width: 90,
    render,
  },
  {
    title: "状态",
    dataIndex: "status",
    // width: 90,
    render: ({ record }) => h(TagStatus, { type: record.vmStatus }),
  },
  {
    title: "云主机数量",
    dataIndex: "status",
    // width: 90,
    render,
  },
  {
    title: "备注",
    dataIndex: "status",
    // width: 90,
    render,
  },
  {
    title: "创建时间",
    dataIndex: "lastTime",
    slotName: "lastTime",
    render,
  },
  {
    title: "操作",
    width: 260,
    dataIndex: "action",
    fixed: "right",
    slotName: "action",
  },
]
export const vmcolumns =[
  {
    title: "名称",
    dataIndex: "name",
    render: ({ record }) => h(LinkText, { label:record?.name,desc:record?.instanceName  }),
    width: 160,
  },
  {
    title: "系统",
    dataIndex: "system",
    tooltip: true,
    ellipsis: true,
    width: 160,
    render: ({ record }) => h(systemType, { type:record?.osType,content:record?.osName  }),
  },
  {
    title: "规格",
    dataIndex: "flavor",
    slotName: "flavor",
    tooltip: true,
    ellipsis: true,
    width: 160,
  },
  {
    title: "IP",
    dataIndex: "vmIps",
    width: 150,
    render: ({ record }) => h(multiLine, { list: record.vmIps?.[0]?.ipAddresses?.map(item => item.ipAddress) }),
  },
  {
    title: "状态",
    dataIndex: "status",
    width: 90,
    render: ({ record }) => h(TagStatus, { type: record.vmStatus }),
  },
  {
    title: "创建信息",
    dataIndex: "lastTime",
    slotName: "lastTime",
    width: 180,
    render: ({ record }) =>h(LinkText, { label: record?.createTime, desc:record?.createBy}),
  },
  {
    title: "变更信息",
    dataIndex: "lastTime",
    slotName: "lastTime",
    width: 180,
    render: ({ record }) =>h(LinkText, { label: record?.lastTime, desc:record?.lastTime}),
  },
  {
    title: "操作",
    width: 80,
    dataIndex: "action",
    fixed: "right",
    slotName: "action",
  },
];
export const relatedcolumns =[
  {
    title: "名称",
    dataIndex: "name",
    render: ({ record }) => h(LinkText, { label:record?.name,desc:record?.instanceName  }),
    width: 160,
  },
  {
    title: "系统",
    dataIndex: "system",
    tooltip: true,
    ellipsis: true,
    width: 160,
    render: ({ record }) => h(systemType, { type:record?.osType,content:record?.osName  }),
  },
  {
    title: "规格",
    dataIndex: "flavor",
    slotName: "flavor",
    tooltip: true,
    ellipsis: true,
    width: 160,
  },
  {
    title: "IP",
    dataIndex: "vmIps",
    width: 150,
    render: ({ record }) => h(multiLine, { list: record.vmIps?.[0]?.ipAddresses?.map(item => item.ipAddress) }),
  },
  {
    title: "业务模型",
    dataIndex: "bizModelName",
    width: 180,
    render,
    // render: ({ record }) => h(multiLine, { type: record.status }),
  },
];